package com.designpattern.fifthchapter;

public class ChocolateBoiler {
	
	private volatile static ChocolateBoiler  instance;
	private boolean empty;
	private boolean boiled;
	
	private ChocolateBoiler() {
		empty = true;
		boiled = false;
	}
	
	public static ChocolateBoiler getInstace() {
		if (instance == null) {
			synchronized (ChocolateBoiler.class) {
				if (instance == null) {
					
					instance = new ChocolateBoiler();
				}
				
			}
			
		}
		return instance;
	}
	
	public void fill() {
		if (isEmpty()) {
			empty = false;
			boiled = false;
		}
	}
	
	public void drain() {
		if (!isEmpty() && isBoiled()) {
			empty = true;
			
		}
	}
	
	public boolean isEmpty(){
		return empty;
	}
	public boolean isBoiled(){
		return boiled;
	}

}
